<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.io.protocol.Allocator</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.io.protocol.Allocator");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461">tango.io.protocol.Allocator</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Initial release: October 2004      
                        Outback release: December 2006<br><br>
<b>author:</b><br>Kris<br><br>        Allocators to use in conjunction with the Reader class. These are
        intended to manage array allocation for a variety of Reader.get&#40;&#41;
        methods<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L30">HeapCopy</a></span>
<script>explorer.outline.addDecl('HeapCopy');</script> : IAllocator;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Simple allocator, copying into the heap for each array requested:
        this is the default behaviour for Reader instances
        
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L38">this</a></span>
<script>explorer.outline.addDecl('this');</script>(IProtocol <span class="funcparam">protocol</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>IProtocol <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L47">protocol</a></span>
<script>explorer.outline.addDecl('protocol');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L56">reset</a></span>
<script>explorer.outline.addDecl('reset');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L64">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(IProtocol.Reader <span class="funcparam">reader</span>, uint <span class="funcparam">bytes</span>, IProtocol.Type <span class="funcparam">type</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd></dl></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L83">HeapSlice</a></span>
<script>explorer.outline.addDecl('HeapSlice');</script> : IAllocator;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Allocate from within a private heap space. This supports reading
        data as 'records', reusing the same chunk of memory for each record
        loaded. The ctor takes an argument defining the initial allocation
        made, and this will be increased as necessary to accomodate larger
        records. Use the reset&#40;&#41; method to indicate end of record &#40;reuse
        memory for subsequent requests&#41;, or set the autoreset flag to reuse
        upon each array request.
        
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L94">this</a></span>
<script>explorer.outline.addDecl('this');</script>(IProtocol <span class="funcparam">protocol</span>, uint <span class="funcparam">width</span> = 4096, bool <span class="funcparam">autoreset</span> = false);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>IProtocol <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L105">protocol</a></span>
<script>explorer.outline.addDecl('protocol');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L116">reset</a></span>
<script>explorer.outline.addDecl('reset');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Reset content length to zero</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L133">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(IProtocol.Reader <span class="funcparam">reader</span>, uint <span class="funcparam">bytes</span>, IProtocol.Type <span class="funcparam">type</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">No allocation: copy into a reserved arena.</font><br><br>
<font color="black">With HeapSlice, it is normal to allocate space large
                enough to contain, say, a record of data. The reserved
                space will grow to accomodate larger records. A reset&#40;&#41;
                call should be made between each record read, to ensure
                the space is being reused.
                
</font><br><br></dd></dl></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L157">BufferSlice</a></span>
<script>explorer.outline.addDecl('BufferSlice');</script> : IAllocator;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Alias directly from the buffer instead of allocating from the heap.
        This avoids both heap activity and copying, but requires some care
        in terms of usage. See methods allocate&#40;&#41; for details
        
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L165">this</a></span>
<script>explorer.outline.addDecl('this');</script>(IProtocol <span class="funcparam">protocol</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>IProtocol <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L174">protocol</a></span>
<script>explorer.outline.addDecl('protocol');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L186">reset</a></span>
<script>explorer.outline.addDecl('reset');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Move all unconsumed data to the front of the buffer, freeing
                up space for more
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/protocol/Allocator.d?rev=3461#L217">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(IProtocol.Reader <span class="funcparam">reader</span>, uint <span class="funcparam">bytes</span>, IProtocol.Type <span class="funcparam">type</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">No alloc or copy: alias directly from buffer. While this is
                very efficient &#40;no heap activity&#41; it should be used only in
                scenarios where content is known to fit within a buffer, and
                there is no conversion of said content e.g. take care when
                using with EndianProtocol since it will convert within the
                buffer, potentially confusing additional buffer clients.</font><br><br>
<font color="black">With BufferSlice, it is considered normal to create a Buffer
                large enough to contain, say, a file and subsequently slice
                all strings/arrays directly from this buffer. Smaller Buffers
                can be used in a record-oriented manner similar to HeapSlice:
                invoke reset&#40;&#41; before each record is processed to ensure here
                is sufficient space available in the buffer to house a complete
                record. GrowBuffer could be used in the latter case, to ensure
                the largest record width is always accomodated.<br><br>                A good use of this is in handling of network traffic, where
                incoming data is often transient and of a known extent. For
                another potential use, consider the quantity of distinct text
                arrays generated by an XML parser -- would be convenient to
                slice all of them from a single allocation instead
               
</font><br><br></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2004 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sun Jun  8 17:12:55 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>